//
//  NYUserPwdCell.m
//  NYTYY
//
//  Created by MinLison on 2017/12/12.
//  Copyright © 2017年 NYtyy. All rights reserved.
//

#import "NYUserPwdCell.h"
#import "NYPwdValidator.h"
@interface NYUserPwdCell ()
@property(nonatomic, strong) QMUIButton *rightView;
@end

@implementation NYUserPwdCell

- (void)setUp
{
        [super setUp];
        [self.leftView setImage:[UIImage login_mi_ma] forState:(UIControlStateNormal)];
        [self.leftView setImage:[UIImage login_mi_ma] forState:(UIControlStateSelected)];
        @weakify(self);
        [self.rightView jk_addActionHandler:^(NSInteger tag) {
                @strongify(self);
                self.rightView.selected = !self.rightView.isSelected;
                self.textField.secureTextEntry = self.rightView.isSelected;
        }];
        self.textField.validator = [[NYPwdValidator alloc] init];
        [self.contentView addSubview:self.rightView];
#if DEBUG
        self.field.value = @"trtr";
#endif
}
- (void)update
{
        [super update];
#if DEBUG
        self.field.value = @"trtr";
        self.textField.text = self.field.value;
#endif
        self.textField.keyboardType = UIKeyboardTypeASCIICapable;
        self.textField.secureTextEntry = YES;
}

- (QMUIButton *)rightView
{
        if (_rightView == nil) {
                _rightView = [[QMUIButton alloc] init];
                _rightView.titleLabel.font = WGSystem14Font;
                _rightView.adjustsTitleTintColorAutomatically = NO;
                _rightView.adjustsButtonWhenHighlighted = NO;
                _rightView.adjustsButtonWhenDisabled = NO;
                //                [_rightView setImage:[UIImage account_btn_show_nor] forState:(UIControlStateNormal)];
                //                [_rightView setImage:[UIImage account_btn_show_sel] forState:(UIControlStateSelected)];
                _rightView.selected = YES;
        }
        return _rightView;
}
@end
